package org.me.marble;


import android.view.*;
import android.widget.*;

import android.content.Context;

/**
*
* @author tungi
*/

class TwoLineArrayAdapter<T> extends ArrayAdapter<T>{
	Context context;
    private T[] line1,line2;
    private CheckBox[] checkbox;
    private int line1Resource,line2Resource,rowResource,checkboxResource;
    
    public TwoLineArrayAdapter(Context context,int rowResource,int checkboxResource,
    		int line1Resource,int line2Resource,T[] line1,T[] line2){
        super(context,rowResource,line1);
        this.line2=line2;
        this.line1=line1;
        this.context=context;
        this.rowResource=rowResource;
        this.line1Resource=line1Resource;
        this.line2Resource=line2Resource;   
        this.checkboxResource=checkboxResource;
        
        checkbox=new CheckBox[3];
  }

    @Override
    public View getView(int position,View reusableView,ViewGroup parent){
        LayoutInflater inflater=(LayoutInflater)
                context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row=inflater.inflate(this.rowResource,null);
        TextView label1=(TextView)row.findViewById(this.line1Resource);
        TextView label2=(TextView)row.findViewById(this.line2Resource);      
                
        checkbox[position]=(CheckBox)row.findViewById(this.checkboxResource);
        
        label1.setText((String)this.line1[position]);
        label2.setText((String)this.line2[position]);
        return row;
    }
    
    public boolean isChecked(int pos){
    	return checkbox[pos].isChecked();
    }
    
    public void setChecked(int pos,boolean checked){
    	checkbox[pos].setChecked(checked);
    }
}
